package com.ayh.campusfun.validators;

import com.ayh.campusfun.common.annotation.validators.PasswordEqual;
import com.ayh.campusfun.dto.RegisterDTO;
import org.apache.axis.utils.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.lang.annotation.Annotation;

/**
 * @author ayh
 * @create 2021/3/26 0026 10:08
 * 密码验证注解绑定类
 */


public class PasswordValidators implements ConstraintValidator<PasswordEqual, RegisterDTO> {
    @Override
    public boolean isValid(RegisterDTO registerDTO, ConstraintValidatorContext constraintValidatorContext) {
        if (StringUtils.isEmpty(registerDTO.getPassword()))
            return false;
        return registerDTO.getPassword().equals(registerDTO.getRePassword());
    }
}
